const app = getApp()
Page({
  data: {
    domainName: app.domainName,
    users:[],
    navActive:{1:'',2:'active',3:''},
    navShow:{1:'hide',2:'',3:'hide'},
    navId: 2,
    kbmData:[],
    jxzData:[],
    yjsData:[]
  },
  onLoad() {
    var _this=this;
    this.getSaiSi('ke');
  },
  chNav(e){
    var _id=e.currentTarget.dataset.id;
    var _navActive={1:'',2:'',3:''};
    var _navShow={1:'hide',2:'hide',3:'hide'};
    _navShow[_id]='';
    _navActive[_id]='active';
    this.setData({navActive:_navActive, navShow:_navShow,navId:_id});
    var _this=this;
    console.log(_id);
    wx.request({
      url: app.domainName + 'web/?c=getsaisi',
      method: 'POST',
      data: {openid:app.globalData.openid,type:_id}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
           if(2 == _id){
               _this.setData({kbmData:res.data.s})
           }
           if(1 == _id){
            _this.setData({jxzData:res.data.s})
          }
          if(3 == _id){
            _this.setData({yjsData:res.data.s})
          }
          
          

      }});

  },
  getSaiSi(_type){
    var _this=this;
    wx.request({
      url: app.domainName + 'web/?c=getsaisiwithuser',
      method: 'POST',
      data: {openid:app.globalData.openid,type:_type}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
           if('ke' == _type){
               _this.setData({kbmData:res.data.s})
           }
           _this.setData({users:res.data.u})
      }});

  },
  gomore(e){
    var _id=e.currentTarget.dataset.id;
    wx.redirectTo({url: '/pages/xiangqing/index?xid='+_id})
    return;
  },
  dobao(e){
    var _id=e.currentTarget.dataset.id;
    this.setbao(_id,'bao');
  },
  setbao(_id,_type){
    var _this=this;
    wx.request({
      url: app.domainName + 'web/?c=dobao',
      method: 'POST',
      data: {openid:app.globalData.openid,type:_type,sid:_id}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        if('n' == res.data.s){
          wx.showToast({
            title: '目前仅支持队长可以报名',
            icon: 'none',
            duration: 1500
          })
          return;
        }
         _this.getSaiSi('ke');
      }});
  },
  quxiao(e){
    var _id=e.currentTarget.dataset.id;
    this.setbao(_id,'quxiao');
  },
  gowode(){
    wx.redirectTo({url: '/pages/zdui/index'})
  },
  gosaicheng(){
    wx.request({
      url: app.domainName + 'web/?c=isduizhang',
      method: 'POST',
      data: {openid:app.globalData.openid}, header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
           console.log(res.data.s);
           if('y' == res.data.s){
            wx.redirectTo({url: '/pages/saisi/index'})
           }else{
            wx.showToast({
              title: '目前仅支持队长可以查看',
              icon: 'none',
              duration: 1500
            })
           }
          
      }});
  },
  doClick(e){
    var _id=e.currentTarget.dataset.id;
    if('noopen' == _id){
       wx.showToast({
         title: '暂未开放',
         icon: 'none',
         duration: 1500
       })
    }
    console.log(_id)
 },
  popMsg(msg){
    wx.showToast({
      title: msg,
      icon: 'none',
      duration: 1500
    })
  }
 
})
